home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
9-Digit Zip Code Directory
/
9-Digit Zip Code Directory (American Business Information) (ABIZIP-12).ISO
/
z4src.zip
/
DIDELETE.C
< prev
next >
Wrap
C/C++ Source or Header
|
1993-05-26
|
3KB
|
106 lines
//----------------------------------------------------------------------------
// MODULE DESCRIPTION
//
// Module: didelete.c
// Title: Data File I/O Library
// Notice: John M. Weeder
// Copyright (c) 1993. All rights reserved.
// This module contains proprietary information and should be
// treated as confidential.
//
//----------------------------------------------------------------------------
// MAINTENANCE HISTORY
//
// $Workfile$
// $Revision$
// $Author$
// $Date$
// $Log$
//
//----------------------------------------------------------------------------
// MODULE NARRATIVE
//
//
// This module contains code to delete a logical file entry from a data file.
//
// The code in this module should be written entirely in C.
// Do not use any C++ constructs.
//
// This module is portable to:
// DOS 3.X+
// MS Windows 3.X+
// OS/2 2.X+
// OS/2 2.0 PM
// SCO UNIX.
//
// The following compilers are supported:
// MSC 6.0A
// MSC/C++ 7.0
// Borland C++ 3.1 for DOS
// Borland C++ 1.0 for OS/2 2.X
// SCO UNIX cc
//
//----------------------------------------------------------------------------
#include <di.h>
//----------------------------------------------------------------------------
// Description: Delete a logical file.
// The physical file is opened and closed when finished.
// The space allocated in the file is wasted!
// Parameters: pcszPhysical Physical file name
// pcsz Logical file name.
// usType File type to delete.
// Returns: TRUE if successful.
//----------------------------------------------------------------------------
BOOL FN_E DioDelete(PCSZ pcszPhysical, PCSZ pcsz, USHORT usType)
{
HPF hpf;
HLF hlf;
SIZET cDir;
DATADIR dir;
BOOL fUser;
BOOL fResult = FALSE;
if (HIUSHORT(pcszPhysical))
{
if (!DioOpenPhysical(pcszPhysical, &hpf, TRUE))
return FALSE;
fUser = FALSE;
}
else
{
hpf = LOUSHORT(pcszPhysical);
Assert(hpf >= 0 && hpf < MAX_PHYSICAL_FILES);
Assert(di.physical[hpf].fUsed);
fUser = TRUE;
}
if (!DioOpenLogical(pcsz, &hlf, usType))
goto ERROR_EXIT;
hpf = di.logical[hlf].hpf;
cDir = di.logical[hlf].cDir;
if (!DioCloseLogical(hlf))
goto ERROR_EXIT;
if (!DioDirRead(hpf, cDir, &dir))
goto ERROR_EXIT;
dir.usType = DFT_DELETED;
if (!DioDirWrite(hpf, cDir, &dir))
goto ERROR_EXIT;
fResult = TRUE;
ERROR_EXIT:
if (!fUser)
DioClosePhysical(hpf);
return fResult;
}
//----------------------------------------------------------------------------
//------------------------------- End of File --------------------------------
//----------------------------------------------------------------------------